package top.yangyitao.dao.impl;

import java.util.List;

import javax.annotation.Resource;

import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.query.Query;
import org.springframework.stereotype.Repository;

import top.yangyitao.dao.ManualDao;
import top.yangyitao.model.Manual;

@Repository("manualDao")
public class ManualDaoImpl implements ManualDao {
	@Resource
	private SessionFactory sessionFactory;
	@Override
	public void saveManual(Manual manual) {
		Session session = sessionFactory.getCurrentSession();
		session.save(manual);
	}

	@SuppressWarnings({ "rawtypes", "unchecked" })
	@Override
	public List<Manual> getAllManual() {
		Session session = sessionFactory.getCurrentSession();
		String hql = "from MANUAL";
		Query query = session.createQuery(hql);
		List<Manual> list = query.list();
		return list;
	}

}
